<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use App\Cache\NoCache;
use App\Cache\Cacheable;

class BackendServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //缓存类服务
        $this->app->bind('TestingCache', function ($app) {
            if (config('cache.enable') == 'true') {
                return new Cacheable();
            } else {
                return new NoCache();
            }
        });


        $this->app->singleton('WechatUserRepository', function($app){
            return new \App\Repositories\WechatUserRepository();
        });
        $this->app->singleton('OrderRepository', function($app){
            return new \App\Repositories\OrderRepository();
        });
        $this->app->singleton('CategoryRepository', function($app){
            return new \App\Repositories\CategoryRepository();
        });
        $this->app->singleton('TestingConfig', function($app){
            return new \App\Repositories\TestingConfigRepository();
        });
        $this->app->singleton('TestingDetailRepository', function($app){
            return new \App\Repositories\TestingDetailRepository();
        });
        $this->app->singleton('TestingItemRepository', function($app){
            return new \App\Repositories\TestingItemRepository();
        });
        $this->app->singleton('ResultTypeRepository', function($app){
            return new \App\Repositories\TestingResultTypeRepository();
        });
        $this->app->singleton('ResultAttributeRepository', function($app){
            return new \App\Repositories\TestingResultAttributeRepository();
        });
        $this->app->singleton('ResultProductRepository', function($app){
            return new \App\Repositories\TestingRecommendProductRepository();
        });
        $this->app->singleton('TestingUserRecordRepository', function($app){
            return new \App\Repositories\TestingUserRecordRepository();
        });

        $this->app->singleton('TestingDeveloperRepository', function($app){
            return new \App\Repositories\TestingDeveloperRepository();
        });
        $this->app->singleton('TestingDevUrlRepository', function($app){
            return new \App\Repositories\TestingDevUrlRepository();
        });
        $this->app->singleton('TestingUserEnterpriseRelRepository', function($app){
            return new \App\Repositories\TestingUserEnterpriseRelRepository();
        });


        /**测评算法帮助类*/
        $this->app->singleton('TestingAlgoHelper', function($app){
            return new \App\Services\TestingAlgoHelper();
        });

        /**新健保测评算法帮助类*/
        $this->app->singleton('TestingXjbHelper', function($app){
            return new \App\Services\TestingXjbHelper();
        });
        $this->app->singleton('TestingXjbAssistHelper', function($app){
            return new \App\Services\TestingXjbAssistHelper();
        });
        $this->app->singleton('TestingXjbUserRecordRepository', function($app){
            return new \App\Repositories\Xjb\TestingXjbUserRecordRepository();
        });
        $this->app->singleton('TestingXjbFactorRepository', function($app){
            return new \App\Repositories\Xjb\TestingXjbFactorRepository();
        });
        /**
         * 新健保計算類
         */
        $this->app->singleton('TestingXjbAlgoHelper', function($app){
            return new \App\Services\TestingXjbAlgoHelper();
        });

        /**
         * 新健保8in1
         */
        $this->app->singleton('CancerXjbItemRepository', function($app){
            return new \App\Repositories\Xjb\CancerXjbItemRepository();
        });
        $this->app->singleton('CancerXjbHelper', function($app) {
            return new \App\Services\CancerXjbHelper();
        });

        /**太保接口验签类*/
        $this->app->singleton('TbCheckRepository', function($app){
            return new \App\Repositories\TbCheckRepository();
        });


        $this->app->singleton('ParamConfigRepository', function($app){
            return new \App\Repositories\ParamConfigRepository();
        });

        $this->app->singleton('DeveloperLinkRepository', function($app){
            return new \App\Repositories\DeveloperLinkRepository();
        });

        $this->app->singleton('ToolsRepository', function($app){
            return new \App\Repositories\ToolsRepository();
        });

        /**
         *轻测echart辅助函数
         */
        $this->app->singleton('DecreaseEchartHelper', function($app){
            return new \App\Services\Echarts\DecreaseEchartHelper();
        });
        /**
         * 接口调用统计
         */
        $this->app->singleton('TestingVisitRepository', function($app){
            return new \App\Repositories\TestingVisitRepository();
        });

        /**
         * 用户做题的tag
         */
        $this->app->singleton('UserTagRepository', function($app){
            return new \App\Repositories\UserTagRepository();
        });
        /**
         *轻测用户详情辅助类
         */
        $this->app->singleton('DecreaseUserInfoHelper', function($app){
            return new \App\Services\Echarts\DecreaseUserInfoHelper();
        });

        /**
         * 减脂平台打卡评价
         */
        $this->app->singleton('AdminEvaluateRepository', function($app){
            return new \App\Repositories\AdminEvaluateRepository();
        });

        /**
         * 减脂平台发送用户打卡提醒
         */
        $this->app->singleton('TestingSendTplUserRepository', function($app){
            return new \App\Repositories\TestingSendTplUserRepository();
        });

        /**
         * DeveloperTestingRel DI
         */
        $this->app->singleton('DeveloperTestingRelRepository', function($app){
            return new \App\Repositories\DeveloperTestingRelRepository();
        });


        /**
         * 减脂平台用户备注
         */
        $this->app->singleton('TestingUserRemarkRepository', function($app){
            return new \App\Repositories\TestingUserRemarkRepository();
        });

        /**
         * 减脂平台用户订单详情表
         */
        $this->app->singleton('JzOrderDetailRepository', function($app){
            return new \App\Repositories\JzOrderDetailRepository();
        });

        /**
         * 减脂平台用户答题订单匹配表
         */
        $this->app->singleton('JzMatchRelationRepository', function($app){
            return new \App\Repositories\JzMatchRelationRepository();
        });
        /**
         *减脂平台v1.5辅助函数
         */
        $this->app->singleton('DecreaseSelectHelper', function($app){
            return new \App\Services\Echarts\DecreaseSelectHelper();
        });

        /**
         *营养师
         */
        $this->app->singleton('JzNutritionistRepository', function($app){
            return new \App\Repositories\JzNutritionistRepository();
        });

        /**
         * 部分测评答案记录
         */
        $this->app->singleton('TestingPartRecordRepository', function($app){
            return new \App\Repositories\TestingPartRecordRepository();
        });

        /**
         * 部分测评题目编号
         */
        $this->app->singleton('TestingPartRepository', function($app){
            return new \App\Repositories\TestingPartRepository();
        });

        /**
         * 测评渠道
         */
        $this->app->singleton('TestingChannelRepository', function($app){
            return new \App\Repositories\TestingChannelRepository();
        });

        /**
         * 用户渠道变更记录
         */
        $this->app->singleton('UserChannelChangeRepository', function($app){
            return new \App\Repositories\UserChannelChangeRepository();
        });

        /**
         * 用户基本信息
         */
        $this->app->singleton('TestingUserInfoRepository', function($app){
            return new \App\Repositories\TestingUserInfoRepository();
        });

        /**
         * 测评数据自动同步
         */
        $this->app->singleton('TestingSyncOrderRepository', function($app){
            return new \App\Repositories\TestingSyncOrderRepository();
        });

        /**
         * 题库信息
         */
        $this->app->singleton('TestingQuestionRepository', function($app){
            return new \App\Repositories\TestingQuestionRepository();
        });
    }
}
